Imports System.Data.SqlClient
Partial Class Parents
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Dim con As SqlConnection
        Dim cmd As SqlCommand
        Dim rdr As SqlDataReader

        Dim urlVar As String = Nothing
        Dim titleVar As String = Nothing
        Dim pageidVar As Integer = Nothing
        Dim pageSubtitleVar As String = Nothing
        Dim pageDescriptionVar As String = Nothing

        con = New SqlConnection(System.Configuration.ConfigurationManager.AppSettings("sqlConn"))
        cmd = New SqlCommand("select * from pages where CMSPage = 0", con)
        con.Open()
        rdr = cmd.ExecuteReader()
        While rdr.Read
            If rdr("url") = "Parents.aspx" Then
                pageidVar = rdr("ID")
            End If
            pageNavigationLabel.Text &= "<li><a href=" & rdr("url") & ">" & rdr("title") & "</a></li>"
        End While
        rdr.Close()
        con.Close()

        cmd = New SqlCommand("select subtitle from pages where url = 'Parents.aspx' and Active = 1", con)
        con.Open()
        rdr = cmd.ExecuteReader()
        While rdr.Read
            pageSubtitleLabel.Text = rdr("subtitle")
        End While
        rdr.Close()
        con.Close()

        cmd = New SqlCommand("select description from pages where url = 'Parents.aspx' and Active = 1", con)
        con.Open()
        rdr = cmd.ExecuteReader()
        While rdr.Read
            pageDescriptionLabel.Text = rdr("description")
        End While
        rdr.Close()
        con.Close()

        cmd = New SqlCommand("select link_text, link_url from link_lists where page_id = 6 and link_type = 'info' and Active = 1", con)
        con.Open()
        rdr = cmd.ExecuteReader()
        While rdr.Read
            infoLinksLabel.Text &= "<h5><a href=" & rdr("link_url") & ">" & rdr("link_text") & "</a></h5>"
        End While
        rdr.Close()
        con.Close()

        cmd = New SqlCommand("select link_text, link_url from link_lists where page_id = 6 and link_type = 'more' and Active = 1", con)
        con.Open()
        rdr = cmd.ExecuteReader()
        While rdr.Read
            moreLinksLabel.Text &= "<h5><a href=" & rdr("link_url") & ">" & rdr("link_text") & "</a></h5>"
        End While
        rdr.Close()
        con.Close()

        cmd = New SqlCommand("select link_text, link_url from link_lists where page_id = 5 and link_type = 'quick' and Active = 1", con)
        con.Open()
        rdr = cmd.ExecuteReader()
        While rdr.Read
            quickLinksLabel.Text &= "<li><a href=" & rdr("link_url") & ">" & rdr("link_text") & "</a></li>"
        End While
        rdr.Close()
        con.Close()

    End Sub
End Class
